package com.xb.controller;
import com.xb.domain.User;
import com.xb.services.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/***
 * @class TestController
 * @description 测试 mybatis springboot
 * @author zch
 * @date 2019/7/13
 * @version V0.0.1.201907131515.01
 * @function function
 * @modfiyDate modfiyDate
 * @createDate createDate
 * @package package
 */
@RestController
@RequestMapping("/test")
public class TestController {
	@Resource
	public UserService userService;
	@RequestMapping("/index")
	public String index() {
		User u = userService.selectByPrimaryKey("%", "root");
		if (null != u) {
			System.out.println(u.toString());
		}
		List<User> allUserList = userService.selectAllUserList();
		if (null == allUserList) {
			User addToUserList = new User();
			addToUserList.setUser("空列表填充 实际并不存在！");
			allUserList = new ArrayList<>();
			allUserList.add(addToUserList);
		}
		return String.valueOf(allUserList);
	}
}
